package app.qrcode.browser.basketballscore

import android.util.Log
import android.view.View
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

/**
 * Created by DomenCai on 2022/2/7.
 */
class MyViewModel : ViewModel() {
    private var aTeamScore = MutableLiveData(0)
    private var bTeamScore = MutableLiveData(0)
    private var aBack: Int = 0
    private var bBack: Int = 0


    fun getaTeamScore(): MutableLiveData<Int> {
        return aTeamScore
    }

    fun getbTeamScore(): MutableLiveData<Int> {
        return bTeamScore
    }

    fun aTeamAdd(p: Int) {
        aBack = aTeamScore.value!!
        bBack = bTeamScore.value!!
        aTeamScore.value = aTeamScore.value?.plus(p)
        Log.w("cdm", "MyViewModel.bTeamAdd -> ${aTeamScore.value}")
    }

    fun bTeamAdd(p: Int) {
        bBack = bTeamScore.value!!
        aBack = aTeamScore.value!!
        bTeamScore.value = bTeamScore.value?.plus(p)
        Log.w("cdm", "MyViewModel.bTeamAdd -> ${aTeamScore.value}")
    }

    fun reset() {
        aBack = aTeamScore.value!!
        bBack = bTeamScore.value!!
        aTeamScore.value = 0
        bTeamScore.value = 0
    }

    fun undo() {
        aTeamScore.value = aBack
        bTeamScore.value = bBack
    }


}